package com.lloyd.animdemo

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView

/**
 * Created by lloyd on 2023/06/06
 * Author: lloyd
 * Date: 2023/06/06 20:46
 * Description: description
 */
class DemoAdapter(val datas: List<String>) : RecyclerView.Adapter<DemoAdapter.DemoVH>() {

    inner class DemoVH(view: View) : RecyclerView.ViewHolder(view) {
        val tvText: TextView = view.findViewById(R.id.tv_text)
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): DemoVH {
        return DemoVH(LayoutInflater.from(parent.context).inflate(R.layout.item_demo, parent, false))
    }

    override fun getItemCount(): Int = datas.size

    override fun onBindViewHolder(holder: DemoVH, position: Int) {
        holder.tvText.text = "$position: ${datas[position]}"
    }

    fun size() = datas.size
}